package parspack;

import java.util.ArrayList;
import java.util.List;

public class Posting {
	// class for Term : Paths
	public String name;
	public String path;
	public List<String> paths;
	Posting(String argn, String argp) {
		name = argn;
		path = argp;
		paths = new ArrayList<String>();
		paths.add(argp);
	}

	// add path to listPaths
	void addPath(String src) {
		this.path += src;
		this.paths.add(src);
	}

	// get list of files for this Term
	List<String> getPaths() {
		List<String> result = new ArrayList<String>();
		String p = this.path;
		while (p.indexOf(".java") > 0) {
			result.add(p.substring(0, p.indexOf(".java") + 5));
			p = p.substring(p.indexOf(".java") + 5);
		}
		return result;
	}

	public boolean equals(Posting obj) {
		return this.name.equals(obj.name);
	}
}
